<template>
  <MenuNavigation />
  <div
    class="exhibits-box jy-style-height"
    id="exhibits-box-id"
    :style="{
      background: `url(${publicUrls + 'free/style9/publicStyle9Bg.png' + '?imageView2/3/format/webp'})`,
    }"
  >
    <div class="top-box">
      <div class="back-box" @click="blankHome">
        <div class="line-box"></div>
        <div class="circle-box"></div>
        <p class="back-text">返回</p>
      </div>
      <div class="title">学术研究</div>
      <div class="screen-layout">
        <div
          class="select-btn-box"
          @click.stop="visible = !visible"
          :style="list.length === 0 && parmas.typeId === 0 ? { opacity: '1', cursor: 'default' } : { opacity: '1' }"
        >
          <span>{{ TypeTitle }}</span>
          <i class="doorIcon" v-if="!visible">&#xe63a;</i>
          <i class="doorIcon" v-else>&#xe63e;</i>
          <div class="menu-box" v-if="visible">
            <div
              :class="{ 'item-active': parmas.typeId === 0 }"
              class="pop-item pop-item-0 hw-click-cursor"
              @click.stop="setTypeId(0)"
            >
              <span
                >全部

                <div class="solider"></div>
              </span>
            </div>
            <div
              :class="{ 'item-active': parmas.typeId === item.id }"
              class="pop-item hw-click-cursor"
              @click.stop="setTypeId(item)"
              v-for="item in props.selectList"
              :key="item.id"
            >
              <span>
                {{ item.text }}
                <div class="solider"></div>
              </span>
            </div>
          </div>
        </div>
      </div>
    </div>

    <div class="center-box">
      <div
        class="exhibits-bg"
        :style="{
          background: `url(${publicUrls + 'free/style9/exhibitsBg.png' + '?imageView2/3/format/webp'})`,
        }"
      >
        <scrollBox
          color="rgba(50, 43, 37, 1)"
          v-if="scrollheight && !loading"
          :byid="986276"
          :width="getScrollHeight"
          :scroll-src="publicUrls + 'free/style9/scrollIcon.png'"
          :scrollId="9"
        >
          <template #solidBorderCon>
            <div class="researches-list" ref="scrollContainers" @scroll="handleScroll">
              <div class="is-null" v-if="list.length === 0 && !loading"><span>暂无学术研究</span></div>
              <div class="item" v-else v-for="item in list" :key="item.id" @click="pathInfo(item.id)">
                <div class="item-left">
                  <div class="title1">
                    <div v-if="item.typeId" class="title1-color">
                      【{{
                        item.typeId == 401792425939013
                          ? '课题研究'
                          : item.typeId == 401792277585989
                          ? '出版刊物'
                          : '论文论著'
                      }}】
                    </div>
                    <div class="title1-names">{{ item.name }}</div>
                  </div>
                  <p class="title3">{{ item.author }}</p>
                </div>
                <div class="item-right">
                  <span class="title2">{{ item.publishedOn }}</span>
                  <span class="title4">{{ item.publisher }}</span>
                </div>
              </div>
            </div>
          </template>
          <template #solidBorderEx>
            <div class="solidBorder-child"></div>
          </template>
        </scrollBox>
      </div>
    </div>
    <div class="content-door">
      <i class="iconfonts">&#xe6dd;</i>
      <span>永不落幕的展览与展示平台</span>
    </div>
  </div>
</template>

<script lang="ts">
export default defineComponent({
  name: 'style9',
});
</script>

<script setup lang="ts">
// @ts-nocheck
import MenuNavigation from '@/freeComponents/menuNavigation/index.vue';
import { publicUrls } from '@/utils/minxin';
import { treeList } from '@/api/user/user';
import RightMenu from '../components/rightMenu.vue';
import Logo from '../components/logo.vue';
import FooterHome from '../components/footerHome.vue';
import PublicTitle from '../components/PublicTitle.vue';
import { useRouter, useRoute } from 'vue-router';
import { ref, watch, reactive, onActivated, nextTick, computed, defineComponent } from 'vue';
import { copyrightSave, copyrightInfo } from '@/api/templates/templates';
import { useProjectStore, commonDataStore } from '@/store';
import { storeToRefs } from 'pinia';
import scrollBox from '../scrollBox.vue';
import { investigationList } from '@/api/investigation/investigation';

const props = defineProps({
  selectList: {
    type: Object,
  },
});
const scrollNumber = ref(0);
const heartbeat = ref(0); //页面心跳值
const store = useProjectStore();
const router = useRouter();
const scrollheight = ref();
const route = useRoute();
const current = ref(1);
const pageSize = ref(20);
const types = ref(true);
const visible = ref(false);
const parmas = reactive({
  value: '',
  pageNo: 1,
  pageSize: 20,
  typeId: 0,
});
const TypeTitle = ref('全部');
const list = ref([]);
const total = ref(0);
const loading = ref(false);
const scrollContainers = ref(null);

let viewportheight = window.innerHeight;
scrollheight.value = (viewportheight / 900) * 558;

const getScrollHeight = computed(() => {
  let rootNode = document.documentElement;

  // 获取计算后的样式
  let computedStyle = window.getComputedStyle(rootNode);

  // 读取字体大小（注意这里返回的可能是一个包含单位的字符串，如"16px"）
  let fontSize = computedStyle.fontSize;

  // 如果你需要一个数字值（不带单位）进行计算，你可能需要解析这个字符串
  // 例如，使用正则表达式或split()方法去除单位，并将结果转换为数字
  let fontSizeNumber = parseFloat(fontSize.replace(/[^0-9.-]/g, ''));
  let heights = (fontSizeNumber / 144) * 480;
  return heights;
});

const init = async (e?: number) => {
  try {
    if (loading.value) {
      return;
    }
    loading.value = true;
    let res = await investigationList(localStorage.getItem('projectId'), parmas);
    total.value = res.data.total;
    if (e) {
      list.value = [];
    }
    list.value = list.value.concat(res.data.data);
    loading.value = false;
    console.log(list.value);
  } catch {
    loading.value = false;
  }
};
const pageWheel = (event: any) => {
  //滚动
  const delta = Math.sign(event.wheelDelta || -event.detail);
  console.log(delta);
  if (delta > 0) {
    scrollContainers.value.scrollTop = scrollContainers.value.scrollTop - 50;
  } else {
    scrollContainers.value.scrollTop = scrollContainers.value.scrollTop + 50;
  }
  event.preventDefault();
  // rightScroll
};
const setTypeId = (e: any) => {
  if (e === 0) {
    parmas.typeId = 0;
    TypeTitle.value = '全部';
  } else {
    parmas.typeId = e.id;
    TypeTitle.value = e.text;
  }
  visible.value = false;
  parmas.pageNo = 1;
  init(2);
};
const handleScroll = () => {
  //滚动加载逻辑

  const scrollContainer = scrollContainers.value;
  const distanceToBottom = scrollContainer.scrollHeight - (scrollContainer.scrollTop + scrollContainer.clientHeight);
  scrollNumber.value = scrollContainer.scrollTop;
  if (distanceToBottom <= 50 && !loading.value && list.value.length < total.value) {
    parmas.pageNo = parmas.pageNo + 1;
    init();
  }
};
const pathInfo = (e: number) => {
  //查看详情
  router.push({
    name: route.meta.loopType ? 'templateresearchLoop' : 'templateresearch',
    query: {
      id: e,
    },
  });
};
init();
onActivated(() => {
  // heartbeat.value
  loading.value = true;
  nextTick(() => {
    loading.value = false;
  });
  if (heartbeat.value !== store.heartbeatCurrent) {
    scrollContainers.value.scrollTop = 0;
    scrollNumber.value = 0;
    parmas.typeId = 0;
    TypeTitle.value = '全部';
    parmas.pageNo = 1;
    init(2);
  } else {
    nextTick(() => {
      scrollContainers.value.scrollTop = scrollNumber.value;
    });
  }
  heartbeat.value = store.heartbeatCurrent;
});
const blankHome = () => {
  router.push({ name: route.meta.loopType ? 'exhibitionHome' : 'templateedit' });
};
</script>

<style lang="less" scoped>
.exhibits-box {
  position: relative;
  width: 100%;
  height: 100%;
  background-size: cover !important;
  background-repeat: no-repeat !important;
  background-position: top center !important;
  padding: 40px 0;
}
.top-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-right: 60px;
}
.back-box {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.line-box {
  flex-shrink: 0;
  width: 140px;
  height: 1px;
  background: #898172;
}
.circle-box {
  flex-shrink: 0;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #898172;
}
.back-text {
  flex-shrink: 0;
  color: #898172;
  font-family: 'SourceHanSerifCN';
  font-size: 18px;
  font-style: normal;
  font-weight: 900;
  line-height: 160%; /* 28.8px */
  margin-left: 2px;
}
.title {
  flex-shrink: 0;
  color: #faeedc;
  text-align: center;
  font-family: 'SourceHanSerifCN';
  font-size: 36px;
  font-style: normal;
  font-weight: 900;
  line-height: 56px; /* 155.556% */
}
.screen-layout {
  position: relative;
  width: 108px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  // cursor: pointer;
}
.select-btn-box {
  cursor: pointer !important;
  span {
    color: #faeedc;
    font-family: 'PingFang SC';
    font-size: 18px;
    font-style: normal;
    font-weight: 400;
    line-height: 24px; /* 133.333% */
  }
  .doorIcon {
    color: #faeedc;
    font-size: 16px;
    margin-left: 8px;
  }
}
.menu-box {
  position: absolute;
  top: 46px;
  left: 20px;
  z-index: 999;
  width: 96px;
  height: auto;
  border-radius: 8px;
  background: #706355;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.item-active {
  span {
    color: #faeedc !important;
    opacity: 1 !important;
  }
  .solider {
    opacity: 1;
  }
}
.pop-item:hover {
  background-color: transparent;
  span {
    opacity: 1;
  }
}
.pop-item {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  span {
    color: #fff;
    font-family: 'PingFang SC';
    font-size: 16px;
    font-style: normal;
    font-weight: 500;
    line-height: 24px; /* 150% */
    white-space: nowrap;
    opacity: 0.6;
  }
}
.solider {
  opacity: 0;
  width: 100%;
  height: 1px;
  background: #faeedc;
}
.center-box {
  position: absolute;
  bottom: 40px;
  left: 0;
  width: 100%;
  padding: 0 60px;
  margin-top: 24px;
}
.exhibits-bg {
  width: 100%;
  height: 740px;
  background-size: 100% 100% !important;
  background-repeat: no-repeat !important;
}
.content-door {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  position: absolute;
  bottom: 0;
  opacity: 0.5;
  .iconfonts {
    font-size: 26px;
    color: #fff;
    margin-bottom: 4px;
    line-height: 32px;
  }
  span {
    font-family: PingFang SC;
    font-size: 16px;
    line-height: 32px;
    color: #fff;
    margin-left: 20px;
    padding-bottom: 7px;
  }
}
.solidBorder-child {
  height: 480px;
  width: 2px;
  background-color: #b1a693;
  opacity: 0.6;
}
::v-deep .unit-exbit-null-remarks-info {
  width: 100%;
  max-height: 740px !important;
  padding: 80px 110px 100px 110px;
  // position: absolute;
  // bottom: 40px;
}
::v-deep .unit-exbi-remarks-info-remarks {
  max-height: 740px !important;
}
::v-deep .solid-box-parent-p {
  top: 50%;
  right: 60px;
  transform: translateY(-50%);
  img {
    width: 22px;
    height: 22px;
    margin-top: 0;
    margin-left: 1px;
  }
}
.item {
  margin-bottom: 40px;
  cursor: pointer;
}
.is-null {
  margin: 0 auto;
  margin-left: 0px;
  margin-top: 200px;
  text-align: center;
  span {
    font-size: 20px;
    line-height: 32px;
    color: rgba(50, 43, 37, 1);
  }
}
.item-left {
  display: flex;
  width: 100%;
}
.title1 {
  width: 70%;
  display: flex;
  align-items: center;
}
.title1-color {
  flex-shrink: 0;
  color: #706355;
  font-family: 'SourceHanSerifCN';
  font-size: 17px;
  font-style: normal;
  font-weight: 700;
  line-height: 32px; /* 188.235% */
}
.title1-names {
  max-width: calc(100% - 220px);
  flex-shrink: 0;
  color: #333;
  font-family: 'SourceHanSerifCN';
  font-size: 17px;
  font-style: normal;
  font-weight: 700;
  line-height: 32px; /* 188.235% */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.title3 {
  width: 100%;
  color: #333;
  text-align: right !important;
  font-family: 'SourceHanSerifCN' !important;
  font-size: 17px;
  font-style: normal;
  font-weight: 500;
  line-height: 32px !important; /* 188.235% */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.item-right {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 2px;
}
.title2 {
  flex-shrink: 0;
  color: #333;
  font-family: 'Microsoft YaHei';
  font-size: 14px;
  font-style: normal;
  font-weight: 400;
  line-height: 26px; /* 185.714% */
  opacity: 0.5;
}
.title4 {
  color: rgba(51, 51, 51, 0.5);
  text-align: right;
  font-family: 'Microsoft YaHei';
  font-size: 14px;
  font-style: normal;
  font-weight: 400;
  line-height: 26px; /* 185.714% */
}
</style>
